package com.flower.oauthserver.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.mvc.condition.RequestConditionHolder;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName DemoServiceImpl
 * @Description TODO
 * @Author 张晓焕
 * @Date 2022/7/12 9:49
 * @Version 1.0
 */
@Service
public class DemoServiceImpl implements UserDetailsService {


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
       // final ServletRequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
       // final HttpServletRequest request = requestAttributes.getRequest();
       // String login_key = request.getHeader("login_key");
        final UserDetails user = User.builder().username("admin").password("1234").authorities("admin").build();
        return user;
    }
}
